package com.launcher.decorator;

import javax.persistence.MappedSuperclass;
import javax.persistence.OneToOne;
import javax.persistence.Transient;

import com.launcher.Rocket;


@MappedSuperclass
public abstract class RocketDecorator extends Rocket
{
	@OneToOne
	protected Rocket decoratedRocket;
	
	@Transient
	protected final String separator = ", ";
	
	public RocketDecorator(Rocket decoratedRocket)
	{
		this.decoratedRocket = decoratedRocket;
	}

	@Override
	public String getParts()
	{
		return decoratedRocket.getParts() + separator + this.getClass().getSimpleName();
	}

	@Override
	public int getTotalCost()
	{
		return decoratedRocket.getTotalCost() + this.getCost();
	}

	@Override
	public int getTotalMass()
	{
		return decoratedRocket.getTotalMass() + this.getMass();
	}
	
	public void setRocketDecorator(Rocket decoratedRocket)
	{
		this.decoratedRocket = decoratedRocket;
	}
	
	public Rocket getRocketDecorator()
	{
		return decoratedRocket;
	}
	
	public abstract Rocket clone();
}
